package com.cjm.one.system.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cjm.one.common.result.Result;
import com.cjm.one.model.system.dto.SysDictDataDto;
import com.cjm.one.model.system.entity.SysDictData;
import com.cjm.one.system.service.SysDictDataService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
@RequestMapping("/admin/system/dict/data")
@Tag(name = "字典数据", description = "字典数据")
public class SysDictDataController {
    @Resource
    private SysDictDataService sysDictDataService;
    @PostMapping("/list")
    @Operation(summary = "分页字典数据列表")
    public Result<Page<SysDictData>>  list(@RequestBody SysDictDataDto sysDictDataDto) {
        return Result.ok(sysDictDataService.getPage(sysDictDataDto));
    }
    @PostMapping
    @Operation(summary = "保存字典数据")
    public Result<Boolean> save(@RequestBody SysDictData sysDictData) {
        return Result.ok(sysDictDataService.save(sysDictData));
    }
    @PutMapping
    @Operation(summary = "修改字典数据")
    public Result<Boolean> update(@RequestBody SysDictData sysDictData) {
        return Result.ok(sysDictDataService.updateById(sysDictData));

    }
    @DeleteMapping("/{id}")
    @Operation(summary = "删除字典数据")
    public Result<Boolean> delete(@PathVariable Long id) {
        return Result.ok(sysDictDataService.removeById(id));
    }
    @GetMapping("/{id}")
    @Operation(summary = "根据id查询字典数据")
    public Result<SysDictData> getById(@PathVariable Long id) {
        return Result.ok(sysDictDataService.getById(id));
    }


}
